package per.sunmes.cl.g;

import per.sunmes.cl.g.gsys.GameActor;
import per.sunmes.cl.g.sys.G;
import per.sunmes.cl.g.sys.GCB;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.Disposable;
import com.badlogic.gdx.utils.viewport.ExtendViewport;

public class CardLandGameMain implements ApplicationListener {
	Stage stage;

	@Override
	public void create() {
		stage = new Stage(new ExtendViewport(G.width, G.height));
		G.stage = stage;
		// ////////
		stage.addActor(new GameActor());
		Gdx.input.setInputProcessor(stage);
	}

	@Override
	public void resize(int width, int height) {
		stage.getViewport().update(width, height);
		GCB.viewUpdateCall();
	}

	@Override
	public void render() {
		stage.act();
		stage.draw();
	}

	@Override
	public void pause() {
		GCB.gamePauseCall();
	}

	@Override
	public void resume() {
		GCB.gameResumeCall();
	}

	@Override
	public void dispose() {
		stage.dispose();
		G.asset.dispose();
		for (Disposable disp : G.caches.values()) {
			disp.dispose();
		}
		G.caches.clear();
	}

}
